home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 52
/
Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso
/
Aminet
/
misc
/
emu
/
Apex-src.lha
/
INSTALL.XPL
< prev
next >
Wrap
Text File
|
2001-09-30
|
4KB
|
179 lines
\INSTALL.XPL APR-10-87
\Resident Code Loader
\Written by Loren Blaney for DFM Engineering
\REVISION HISTORY:
\SEP-26-86, ORIGINAL
\FEB-13-87, Changed MEMTOP to $80000 for Amiga, added display of MEMTOP,
\ and show when bytes are outside legal load range.
\APR-10-87, Changed string conventions.
\
\NOTES:
\This program is used to load code into the resident area of Apex. It
\ writes directly to the boot disk. The disk must be rebooted to
\ actually load the modified RESCOD into memory. It is most often used
\ to install device handlers, but it will install anything within the
\ upper and lower portions of RESCOD memory (this includes INT).
code
ABS=0, RAN=1, REM=2, RESERVE=3,
SWAP=4, EXTEND=5, RESTART=6, CHIN=7,
CHOUT=8, CRLF=9, INTIN=10, INTOUT=11,
TEXT=12, OPENI=13, OPENO=14, CLOSE=15,
SCAN=24, FWRITE=30, FREAD=31, HEXOUT=27;
def INTSIZE=4; \Number of bytes in an integer (2 or 4)
def RESSIZE=80; \Number of blocks in RESCOD.SYS. (WARNING: If this
\ value is changed, must also change error message)
def TV=0, KB=0;
def BEL=$07, EOF=$1A;
int MEMTOP, \Highest memory location +1
UNIT, \Unit number containing RESCOD.SYS
PC, \The current relative load address
CHAR, \Character read in by GETCH from disk
BLOCK; \Holds start and end blocks of SCANed file
addr BUFFER; \Holds the loaded file which is written to disk
proc ERROR(STR); \Display error message and exit
addr STR;
begin
TEXT(TV,"
OH OH - ");
CHOUT(TV,BEL);
TEXT(TV,STR);
CRLF(TV);
exit;
end; \ERROR
func SWAPWD(I); \Swap words in a 32-bit integer
int I;
addr A;
int T;
begin
A:= addr I;
T:=A(0); A(0):=A(2); A(2):=T;
T:=A(1); A(1):=A(3); A(3):=T;
return I;
end; \SWAPWD
proc GETCH; \Get CHAR from disk, filter out CR's, etc.
begin
loop begin
CHAR:= CHIN(3);
if CHAR>$20 then quit;
if CHAR=EOF then quit;
end;
end; \GETCH
func HEXNYBBLE; \Return the value of the hex nybble
int HEX;
begin
case of
CHAR>=^0 & CHAR<=^9: HEX:= CHAR -^0;
CHAR>=^A & CHAR<=^F: HEX:= CHAR -$37
other ERROR("HEX CHARACTER EXPECTED");
GETCH; \Look ahead one character
return HEX;
end; \HEXNYBBLE
func HEXBYTE; \Read in 2 chars and return the value of the hex byte
begin
return HEXNYBBLE <<4 + HEXNYBBLE;
end; \HEXBYTE
func HEXWORD; \Read in 4 chars and return the value of the hex word
begin
return HEXBYTE <<8 + HEXBYTE;
end; \HEXWORD
func HEXLONG; \Read in 8 chars and return the value of the hex long
begin
return SWAPWD(HEXWORD) +HEXWORD;
end; \HEXLONG
proc STOBYTE(BYTE); \Store a byte at the current PC
int BYTE;
begin
if PC>=$0000 & PC<$1000 then \Only store bytes within legal range
BUFFER(PC):= BYTE;
if PC>=MEMTOP-$4000 & PC<MEMTOP then
BUFFER(PC -MEMTOP +$5000):= BYTE;
case of
PC>=MEMTOP-$4000 & PC<MEMTOP:
BUFFER(PC -MEMTOP +$5000):= BYTE;
PC>=$0000 & PC<$1000: \Only store bytes within legal range
BUFFER(PC):= BYTE
other CHOUT(TV,^-); \Indicate something is being chopped
PC:= PC +1;
end; \STOBYTE
begin \MAIN
BUFFER:= RESERVE(RESSIZE *$100);
BLOCK:= RESERVE(2 *INTSIZE);
MEMTOP:= $80000;
TEXT(TV,"-- RESIDENT CODE INSTALLER, V1.0x3 --
MEMTOP: $"); HEXOUT(TV, MEMTOP);
TEXT(TV,"
WHICH UNIT (0-7)? ");
UNIT:= INTIN(KB);
SCAN(UNIT, BLOCK, "RESCOD SYS");
if BLOCK(0)#17 then
ERROR("RESCOD.SYS MUST BE THE FIRST FILE ON THE DISK");
if BLOCK(1) - BLOCK(0) + 1 # RESSIZE then
ERROR("RESCOD.SYS MUST BE 80 BLOCKS LONG");
TEXT(TV,"LOADING... ");
FREAD(UNIT, 17, BUFFER, RESSIZE);
\Now load the code to be installed:
PC:= 0; \Default PC
OPENI(3);
GETCH;
loop begin
case CHAR of
^@: [GETCH; PC:= HEXLONG];
EOF: quit
other STOBYTE(HEXBYTE);
end;
TEXT(TV,"
MODIFYING ");
INTOUT(TV,UNIT);
TEXT(TV,":RESCOD.SYS - ARE YOU SURE (N/Y)? ");
OPENI(KB);
if (CHIN(KB) ! $20) = ^y then
begin
FWRITE(UNIT, 17, BUFFER, RESSIZE);
TEXT(TV,"THE DEED IS DONE");
end
else TEXT(TV,"OK, IT'S NOT MODIFIED");
CRLF(TV);
end; \MAIN
IT, 17, BUFFER, RESSIZE);
TEXT(TV,"THE DEED IS DONE")